//
//  CXOtherCollectionViewCell.m
//  GiftThat
//
//  Created by ChuXiang on 16/1/7.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "CXOtherCollectionViewCell.h"
@interface CXOtherCollectionViewCell ()
@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) UILabel *titleLabel;
@end

@implementation CXOtherCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.image = [UIImageView new];
//        self.image.layer.cornerRadius = self.height / 10;
//        self.image.layer.masksToBounds = YES;
        [self addSubview:self.image];
        
        
        self.titleLabel = [UILabel new];
        [self.titleLabel setFont:[UIFont fontWithName:@"FZLanTingHei-EL-GBK" size:13]];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.titleLabel];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    
    self.image.frame = CGRectMake(10, 0, self.width - 20, self.height - self.height / 4);
    self.titleLabel.frame = CGRectMake(self.image.left, self.image.bottom, self.image.width, self.height / 4);
    
}

- (void)setModel:(CXOtherModel *)model {
    if (self.model != model) {
        if (model) {
            [self.image sd_setImageWithURL:[NSURL URLWithString:model.icon_url]];
            self.titleLabel.text = model.name;
        }
    }
}

@end
